﻿@using DuocThaiBinh.WebUI.HtmlHelpers
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="duocthaibinh">
    <meta name="author" content="TungPT">
    <title>@ViewBag.Title - Dược Thái Bình</title>
    @Styles.Render("~/Content/css")

    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/bootstrapgeneral")

    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    
    <script type="text/javascript">
        function ChangeKhoFunc(id) {
            var serviceURL = "@Url.Action("ChangeCuaHang", "CuaHang")";

            $.ajax({
                type: "POST",
                url: serviceURL,
                data: "{ 'cuaHangID': '" + id + "' }",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data !== 'done') {
                        alert("Có lỗi khi chuyển cửa hàng. Vui lòng quay lại trang chủ.");
                        document.location.href = "@Url.Action("Index", "Home")";
                    } else {
                        location.reload();
                    }
                },
                error: function (data) {
                    alert("Có lỗi khi chuyển kho hàng. Vui lòng quay lại trang chủ.");
                    document.location.href = "@Url.Action("Index", "Home")";
                }
            });
        }
    </script>
</head>
<body>
    <div id="wrapper">
        @if (Request.IsAuthenticated)
        {
            <!-- Navigation -->
            <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="@Url.Action("Index", "Home")">Dược Thái Bình</a>
                </div>
                <!-- /.navbar-header -->

                <ul class="nav navbar-top-links navbar-right">
                    @Html.Partial("_LoginPartial")
                </ul>
                <!-- /.navbar-top-links -->

                <div class="navbar-default sidebar" role="navigation">
                    <div class="sidebar-nav navbar-collapse">
                        <ul class="nav" id="side-menu">

                            @{var currentRole = Roles.GetRolesForUser(User.Identity.Name);}

                            <li>
                                <a href="#"><i class="fa fa-bar-chart-o fa-fw"></i> Kho Hàng và Sản Phẩm<span class="fa arrow"></span></a>
                                <ul class="nav nav-second-level">
                                    @if (currentRole.Contains("Administrator"))
                                    {
                                        <li><a href="@Url.Action("Index", "CuaHang")" target="_self">Cửa hàng</a></li>
                                        <li><a href="@Url.Action("Index", "Kho")" target="_self">Kho</a></li>
                                        <li><a href="@Url.Action("Index", "SanPham")" target="_self">Danh mục Sản Phẩm</a></li>
                                        <li><a href="@Url.Action("Index", "CauHinhSanPhamTrongKho")" target="_self">Cấu hình Sản Phẩm trong Kho</a></li>
                                        <li><a href="@Url.Action("Index", "ThongKe")" target="_self">Thống kê tồn kho</a></li>
                                        <li><a href="@Url.Action("Index", "DVCC")" target="_self">Đơn vị cung cấp</a></li>
                                        <li><a href="@Url.Action("Index", "KhachHang")" target="_self">Khách hàng</a></li>
                                    }
                                    else
                                    {
                                        if (currentRole.Contains("Staff"))
                                        {
                                        <li><a href="@Url.Action("Index", "SanPham")" target="_self">Sản Phẩm</a></li>
                                        <li><a href="@Url.Action("Index", "DVCC")" target="_self">Đơn vị cung cấp</a></li>
                                        }
                                        if (currentRole.Contains("StaffXuatKho"))
                                        {
                                        <li><a href="@Url.Action("Index", "SanPham")" target="_self">Sản Phẩm</a></li>
                                        <li><a href="@Url.Action("Index", "KhachHang")" target="_self">Khách hàng</a></li>
                                        }
                                    }

                                </ul>
                            </li>
                            <li>
                                <a href="#"><i class="fa fa-bar-chart-o fa-fw"></i> Hóa đơn<span class="fa arrow"></span></a>
                                <ul class="nav nav-second-level">
                                    @if (currentRole.Contains("Administrator"))
                                    {
                                        <li><a href="@Url.Action("Index", "NhapKho")" target="_self">Nhập Kho</a></li>
                                        <li><a href="@Url.Action("IndexGrid", "XuatKho")" target="_self">Xuất Kho</a></li>
                                        <li><a href="@Url.Action("IndexKH", "ThanhToan")" target="_self">Thanh toán</a></li>
                                        <li><a href="@Url.Action("Index", "ChuyenKho")" target="_self">Chuyển Kho</a></li>
                                    }
                                    else
                                    {
                                        if (currentRole.Contains("Staff"))
                                        {
                                        <li><a href="@Url.Action("Index", "NhapKho")" target="_self">Nhập Kho</a></li>
                                        }
                                        if (currentRole.Contains("StaffXuatKho"))
                                        {
                                        <li><a href="@Url.Action("IndexGrid", "XuatKho")" target="_self">Xuất Kho</a></li>
                                        }
                                        if (currentRole.Contains("Staff") || currentRole.Contains("StaffXuatKho"))
                                        {
                                        <li><a href="@Url.Action("IndexKH", "ThanhToan")" target="_self">Thanh toán</a></li>
                                        }
                                    }
                                </ul>
                            </li>
                            @if (currentRole.Contains("Administrator"))
                            {
                                <li><a href="@Url.Action("Index", "Account")" class="@Html.ActivePage(",Account,")"><span>Tài khoản</span></a></li>
                                <li><a href="@Url.Action("ThongKe", "Home")" class="@Html.ActivePage(",Home11,")"><span>Thống kê</span></a></li>
                            }
                        </ul>
                    </div>
                    <!-- /.sidebar-collapse -->
                </div>
                <!-- /.navbar-static-side -->
            </nav>
        }
        <div id="page-wrapper">
            <div class="row">
                @RenderBody()       
            </div>
        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->

    @RenderSection("scripts", required: false)
</body>
</html>
